package bis;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

public class FLCustomerMgr extends FLBaseMgr {

    private ArrayList GetDate() {
        ArrayList list = new ArrayList();
        ResultSet rs = super.Query();
        try {
            while (rs.next()) {
                FLCustomer flc = new FLCustomer(rs.getString(1), rs.getString(2), rs.getString(3));
                list.add(flc);
            }
        } catch (SQLException ex) {
            Logger.getLogger(FLManagerMgr.class.getName()).log(Level.SEVERE, null, ex);
        }
        if (list.isEmpty()) {
            return null;
        } else {
            return list;
        }
    }

    public ArrayList GetDateById(String id) {
        QueryStr = "select * from tblCustomer where mc='" + id + "'";
        return GetDate();
    }

    public ArrayList GetAllDate() {
        QueryStr = "select * from tblCustomer";
        return GetDate();
    }

    public void flcdelete(String bm) {
        this.bm = bm;
        this.BaseDelete();

    }

    public boolean isInsert(String bm, String mc, String mm) {
        InsertStr = "insert into tblCustomer(Bm, mc,mm) values('" + bm + "','" + mc + "','" + mm + "')";
        return Insert();
    }

    public void setUpdate(FLCustomer aflc) {
        QueryStr = "select * from tblCustomer where Bm='" + aflc.bm + "'";
        super.UpdateStr = "update tblCustomer set mc='" + aflc.mc + "',mm='" + aflc.mm + "' where Bm='" + aflc.bm + "'";
        super.BaseUpdate();
    }

    @Override
    public void BaseDelete() {
        QueryStr = "select bm from tblCustomer where Bm='" + bm + "'";
        UpdateStr = "delete from tblCustomer where Bm='" + bm + "'";
        super.BaseDelete();
    }
}
